/*
 * @Description:
 * @Author:
 * @Date: 2021-03-03 09:25:04
 * @LastEditTime: 2021-11-24 18:20:23
 * @LastEditTime: 2021-06-03 18:22:19
 */
import { del, get, patch, post, put } from './ajax';

const fnRes = (res: any) => JSON.parse(res.request.response);

// ------------------------------登录---------------------------------
export const getUserLoginInfo = (data: any) => get(`/appspace/v1/users/my-login-info`, data).then(fnRes); // 获取当前用户登录信息
export const sendSms = (data: any) => post(`/appspace/v1/common/sendSms`, data).then(fnRes); // 发送验证码
export const usersEdit = (data: any) => put(`/appspace/v1/users/${data.id}`, data).then(fnRes); //修改用户
// ----头像上传----
// export const usersUploadProfile = (data: any) => post(`/se-auth/v1/users/upload-profile`, data).then(fnRes); // 头像上传
// export const commonImgPicture = (data: any) => get(`/se-auth/v1/common/picture?objectId=${data}`, data).then(fnRes); // 图片展示
// ----认证管理----
export const AppspaceCompany = (data: any) => post(`/appspace/v1/company`, data).then(fnRes); // 创建企业实名信息
export const getAppspaceCompany = (data: any) => get(`/appspace/v1/company/${data.id}`, data).then(fnRes); // 获取企业实名信息
export const editAppspaceCompany = (data: any) => put(`/appspace/v1/company/${data.id}`, data).then(fnRes); // 修改企业实名信息
export const getCompanyVerifyQuery = (data: any) => post(`/appspace/v1/company/query/${data.id}`, data).then(fnRes); //获取认证状态
export const getCompanyVerify = (data: any) => post(`/appspace/v1/company/verify/${data.companyId}`, data).then(fnRes); //验证企业支付金额

// ----数据台账----
export const ledgersList = (data: any) => get(`/appspace/v1/ledgers`, data).then(fnRes); // 获取数据台账列表
export const ledgersCreate = (data: any) => post(`/appspace/v1/ledgers`, data).then(fnRes); // 创建数据台账
export const ledgersEdit = (data: any) => put(`/appspace/v1/ledgers/${data.id}`, data).then(fnRes); // 修改数据台账
export const ledgersDelete = (data: any) => patch(`/appspace/v1/ledgers`, data).then(fnRes); // 删除数据台账

// ----应用授权----
export const appAuthList = (data: any) => get(`/appspace/v1/app-auth`, data).then(fnRes); // 获取企业列表
export const appPass = (data: any) => put(`/appspace/v1/app-auth/apply/${data.id}/`, data).then(fnRes); // 审批通过
export const appDeny = (data: any) => put(`/appspace/v1/app-auth/decline/${data.id}`, data).then(fnRes); // 审批拒绝
export const appBacthPass = (data: any) => put(`/appspace/v1/app-auth/apply-all`, data).then(fnRes); // 批量通过

// --- 统一认证中心
export const ssoLogin = (data: any) => post(`/appspace/v1/users/sms-login`, data).then(fnRes); // sso登录
export const getCodeToToken = (data: any) => post(`/appspace/oauth/client/callback`, data).then(fnRes); // 通过code获取token
// ------------------------------首页统计相关接口---------------------------------
export const getHomeWasteDiscriminate = (data: any) => get(`/appspace/v1/home/waste-discriminate`, data); // 获取能耗浪费
export const getHomeServiceOverview = (data: any) => get(`/appspace/v1/home/service-overview`, data); // 获取服务总览
export const getHomeMonitorEnt = (data: any) => get(`/appspace/v1/home/monitor-ent`, data); // 获取监控企业
export const getHomeMainDetail = (data: any) => get(`/appspace/v1/home/main-detail`, data); // 获取主体详情
export const getHomeIndustry = (data: any) => get(`/appspace/v1/home/industry`, data); // 获取行业碳价值top5
export const getHomeEnt = (data: any) => get(`/appspace/v1/home/ent`, data); // 获取碳服务企业top5
export const getHomeEnergyOverview = (data: any) => get(`/appspace/v1/home/energy-overview`, data); // 获取能耗总览
export const getHomeCarbonOverview = (data: any) => get(`/appspace/v1/home/carbon-overview`, data); // 获取碳排放总览
